using System;
using UnityEngine;
using System.Collections;

public class LoginLoadingUIHandler : GameUIHandler< LoginLoadingUIHandler >
{
	AsyncOperation async = null;

	public LoginLoadingUIHandler ()
	{

	}


	void Awake ()
	{
		mInstance = this;
	}
	
	public override void onRelease()
	{
		
	}
	public override void onInit()
	{
		
	}
	public override void onOpen()
	{
		
	}
	public override void onClose()
	{
		
	}
	
	public void loadScene( int s )
	{
		//Application.LoadLevel( 1 );

		StartCoroutine( loadSceneCoroutine( s ) );
	}
	
	
	IEnumerator loadSceneCoroutine( int s )
	{
		async = Application.LoadLevelAsync( s );
		
		yield return async;
	}
	
	
	// Use this for initialization
	void Start () 
	{
		//Show();
	}
	
	
	// Update is called once per frame
	void Update () 
	{
		if ( async != null )
		{
			//async.progress

			if ( async.progress == 1 && LoadingUIHandler.instance != null )
			{
				LoginUIHandler.instance.Release();
				LoginLoadingUIHandler.instance.Release();

				async = null;
			}
		}
		
	}

}

